package com.ruoyi.web.controller.app.controller;

import com.ruoyi.framework.web.exception.base.XResult;
import com.ruoyi.web.controller.app.service.AppGiveLikeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Map;

/**
 * @ClassName MyGiveLikeController
 * @Description TODO
 * @Author tyc@yanyu
 * @Date 2018/12/12 0012 15:17
 **/
@RestController
@RequestMapping("/app/mygivelike")
@Api(tags = "点赞管理")
public class AppGiveLikeController {
    @Autowired
    private AppGiveLikeService myGiveLikeService;

    @RequestMapping(value = "giveLike",method = RequestMethod.POST)
    @ApiOperation(value = "点赞",position = 1,notes = "点赞")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "memberId", value = "用户ID", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "dynamicId", value = "动态id", required = true, dataType = "String", paramType = "query")
    })
    public XResult giveLike(@RequestParam @ApiIgnore Map<String,String> map){
        return new XResult("操作成功",myGiveLikeService.giveLike(map));
    }

    @RequestMapping(value = "cancleGiveLike",method = RequestMethod.POST)
    @ApiOperation(value = "取消点赞",position = 2,notes = "取消点赞")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "memberId", value = "用户ID", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "dynamicId", value = "动态id", required = true, dataType = "String", paramType = "query")
    })
    public XResult cancleGiveLike(@RequestParam @ApiIgnore Map<String,String> map){
        return new XResult("操作成功",myGiveLikeService.cancleGiveLike(map));
    }

    @RequestMapping(value = "giveLikeNum",method = RequestMethod.POST)
    @ApiOperation(value = "统计点赞数量",position = 3,notes = "统计点赞数量")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dynamicId", value = "动态id", required = true, dataType = "String", paramType = "query")
    })
    public XResult giveLikeNum(String dynamicId){
        return new XResult("操作成功",myGiveLikeService.getNumbyId(dynamicId));
    }
}
